import 'package:flutter/material.dart';

import 'package:shop/src/app.dart';
import 'package:shop/page/detail_page.dart';
import 'package:shop/page/goods_page.dart';

const tabbar = '/';
const detailPage = 'DetailPage';
const goodsPage = 'GoodsPage';

final tabbarPagekey = GlobalKey();
final cartPagekey = GlobalKey();

final routes = {
  tabbar: (context) => TabbarPage(
        key: tabbarPagekey,
      ),
  detailPage: (context, arguments) => DetailPage(
        arguments: arguments,
      ),
  goodsPage: (context, arguments) => GoodsPage(
        arguments: arguments,
      ),
};

class Routes {
  static MaterialPageRoute setRouts(RouteSettings settings) {
    return MaterialPageRoute(
        settings: settings,
        builder: (BuildContext context) {
          var pageBuilder = routes[settings.name];
          if (settings.name != null) {
            if (settings.arguments != null) {
              return pageBuilder!(context, settings.arguments);
            } else {
              return pageBuilder!(context);
            }
          } else {
            return TabbarPage();
          }
        });
  }
}
